import React, { Component } from "react";
import Header from "../../components/Header/Header";

import { Button, Toast } from "antd-mobile";
import { connect } from "react-redux";
import { bindActionCreators } from "redux";
import { actions, getUser } from "../../store/modules/login";
class Login extends Component {
  render() {
   
    let {
      user,
      l: { changeUser, doLogin },
      history: { push },
    } = this.props;
   
    return (
      <div>
        {" "}
        <Header register title="登录" {...this.props}></Header>
        <div>user: {JSON.stringify(user)}</div>
        <div>
          账号：{" "}
          <input
            type="text"
            onChange={(e) => {
              changeUser("phone", e.target.value);
            }}
            value={user.phone}
            placeholder="账号"
          />
        </div>
        <div>
          密码：{" "}
          <input
            type="text"
            onChange={(e) => {
              changeUser("password", e.target.value);
            }}
            value={user.password}
            placeholder="请输入密码"
          />
        </div>
        <Button onClick={() => doLogin(push)}>登录</Button>
      </div>
    );
  }
}
const mapStateToprops = (state) => {
  return {
    user: getUser(state),
  };
};
const mapDispatchToprops = (dispatch) => {
  return {
    l: bindActionCreators(actions, dispatch),
  };
};
export default connect(mapStateToprops, mapDispatchToprops)(Login);
